<?php
require('ucCheck.php');

$userSysArr = Cache::PhpFile('userSys');
$tplSysArr = Cache::PhpFile('tplSys');

if ($userSysArr['US_isUserSys'] == 0){
	die('<br /><br /><center>会员系统已关闭，有问题请联系管理员</center>');
}

// 如果手机端访问，手机版有开启，判断手机版独立域名有开启使用，当前网址不是独立域名进行跳转
if ( UcBase::JudMobile() ){
	$wapArr = Cache::PhpFile('wap');
	$currUrl = GetUrl::Query();
	$currDir = GetUrl::Dir();
	if ($wapArr['WAP_domainMode'] == 1 && strlen($wapArr['WAP_domainUrl']) > 7 && strpos($currUrl,$wapArr['WAP_domainUrl']) === false){
		$currUrl = str_replace(array($currDir, 'index.php'), array($wapArr['WAP_domainUrl'] .'users/', ''), $currUrl);
		header('Location: '. $currUrl);
		exit();
	}
}

$logo = $logoStr = '';
if (strlen($tplSysArr['TS_logo']) > 0){
	$logo = $tplSysArr['TS_logo'];
}elseif (strlen($tplSysArr['TS_fullLogo']) > 0){
	$logo = $tplSysArr['TS_fullLogo'];
}
if (strlen($logo) > 0){
	if ( ! Is::HttpUrl($logo) ){
		$logo = UcBase::BeforeURL() . ImagesFileDir . $logo;
	}
	$imgAlt = Str::MoreReplace($systemArr['SYS_title'],'input');
	$logoStr = '<center><img src="'. $logo .'" alt="'. $imgAlt .'" title="'. $imgAlt .'" class="logoImg" /></center>';
}



require(OT_ROOT .'cache/php/userApi.php');
require(OT_ROOT .'inc/classTemplate.php');

$tpl = new Template;
$tpl->obj->template_dir	= OT_ucROOT .'template/default/';	// 模板目录

// 初始化公共变量
$tpl->webTypeName	= 'users';
$tpl->webTitle		= '';
$tpl->webKey		= $systemArr['SYS_webKey'];
$tpl->webDesc		= $systemArr['SYS_webDesc'];

switch ($mudi){
	case 'reg':
		$webTitle	= '会员注册';
		$webContent = UcUsers::RegWeb();
		break;


	case 'missPwd':
		$webTitle	= '忘记密码';
		$webContent = UcUsers::MissPwdWeb();
		break;

	case 'login':
	default :
		$webTitle	= '会员登录';
		$webContent = UcUsers::LoginWeb();
		break;
		// die('no mudi');
		// break;
}

$tpl->webTitle = $webTitle .'_'. $systemArr['SYS_title'];


if (AppWeixinJs::Jud() || AppWeixin::Jud()){
	if (empty($appSysArr)){ $appSysArr = Cache::PhpFile('appSys'); }
	$imgDef = Info::InfoImgUrl($appSysArr['AS_weixinImgDef'], $systemArr['SYS_URL'] . ImagesFileDir);

	if (UcBase::JudWapDomain()){
		$currUrl = $systemArr['SYS_wapUrl'] .'users/';
	}else{
		$currUrl = $systemArr['SYS_URL'] .'wap/users/';
	}
	if (strlen($mudi) > 0){ $currUrl .= '?m='. $mudi; }

	$webContent .= AppWeixinJs::ShareJs($currUrl, $tpl->webTitle, $imgDef, Str::MoreReplace($tpl->webDesc,'js'));
}

$tpl->Add('isMobile',		UcBase::JudMobile() ? 1 : 0);
$tpl->Add('siteVer',		OT_VERSION);
$tpl->Add('webTypeName',	$tpl->webTypeName);
$tpl->Add('webTitle',		$tpl->webTitle);
$tpl->Add('webContent',		$webContent);

$tpl->Show('ucIndex.html');
?>